import { Injectable,EventEmitter } from '@angular/core';
import { Router } from '@angular/router';
import {ReplaySubject} from 'rxjs';
import {HttpClient} from '@angular/common/http';


@Injectable()

export class DragdropService{
    private current: ReplaySubject<any> = new ReplaySubject<any>( 1 );   //保存拖动的节点的名字
    private dragsarray:ReplaySubject<any> = new ReplaySubject<any>( 1 )  //被拖动的数组
    private dropEl:EventEmitter<any>;                            //删除已拖动的元素
    private dropevent:EventEmitter<any>;
    private dropev:ReplaySubject<any> = new ReplaySubject<any>( 1 ) 
    private dragcol:ReplaySubject<any> = new ReplaySubject<any>( 1 )
    private dragcolarray:ReplaySubject<any> = new ReplaySubject<any>( 1 )
    private dragstyle:ReplaySubject<any> = new ReplaySubject<any>( 1 )   //拖动level的时候保存type
    private dragcolstyle:ReplaySubject<any> = new ReplaySubject<any>( 1 ) //拖动column的时候保存type
    private filterdrag:ReplaySubject<any> = new ReplaySubject<any>( 1 )   //拖动过滤存储数据
    private filterdragarray:ReplaySubject<any> = new ReplaySubject<any>( 1 )  //拖动过滤的数组
    private filterEl:EventEmitter<any>;

    private measuredrag:ReplaySubject<any> = new ReplaySubject<any>( 1 )     //指标
    private measuredragarray:ReplaySubject<any> = new ReplaySubject<any>( 1 )
   
    constructor(){
        this.dropEl=new EventEmitter()
        this.filterEl=new EventEmitter()
    }

    setdrag(data1:any,data2:any,data3:any){
        this.current.next(data1)
        this.dragstyle.next(data2)
        this.dragsarray.next(data3)
    }
    getdrag(){
        console.log(1)
        return {a:this.current,b:this.dragstyle,c:this.dragsarray}
    }

    setdragcol(data3:any,data4:any,data5:any){
        this.dragcol.next(data3)
        this.dragcolstyle.next(data4)
        this.dragcolarray.next(data5)
    }
    getdragcol(){
        console.log(2)
        return {a:this.dragcol,b:this.dragcolstyle,c:this.dragcolarray}
    }

    filtersetdrag(data1:any,data2:any){
        console.log(data1)
        this.filterdrag.next(data1)
        this.filterdragarray.next(data2)
    }
    filtergetdrag(){
        console.log(this.filterdrag)
        return {a:this.filterdrag,b:this.filterdragarray}
    }

    setmeasuredrag(data1:any,data2:any){
        console.log(data1)
        this.measuredrag.next(data1)
        this.measuredragarray.next(data2)
    }
    getmeasuredrag(){
        console.log(this.measuredrag)
        return {a:this.measuredrag,b:this.measuredragarray}
    }





}